package com.hjm.project.bankCardtype.bankCardtype.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.bankCardtype.bankCardtype.domain.BankCardtype;
import com.hjm.project.bankCardtype.bankCardtype.service.IBankCardtypeService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 签购单Controller
 * 
 * @author LOVE
 * @date 2020-11-28
 */
@Controller
@RequestMapping("/bankCardtype/bankCardtype")
public class BankCardtypeController extends BaseController
{
    private String prefix = "bankCardtype/bankCardtype";

    @Autowired
    private IBankCardtypeService bankCardtypeService;

    @RequiresPermissions("bankCardtype:bankCardtype:view")
    @GetMapping()
    public String bankCardtype()
    {
        return prefix + "/bankCardtype";
    }

    /**
     * 查询签购单列表
     */
    @RequiresPermissions("bankCardtype:bankCardtype:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BankCardtype bankCardtype)
    {
        startPage();
        List<BankCardtype> list = bankCardtypeService.selectBankCardtypeList(bankCardtype);
        return getDataTable(list);
    }

    /**
     * 导出签购单列表
     */
    @RequiresPermissions("bankCardtype:bankCardtype:export")
    @Log(title = "签购单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BankCardtype bankCardtype)
    {
        List<BankCardtype> list = bankCardtypeService.selectBankCardtypeList(bankCardtype);
        ExcelUtil<BankCardtype> util = new ExcelUtil<BankCardtype>(BankCardtype.class);
        return util.exportExcel(list, "bankCardtype");
    }

    /**
     * 新增签购单
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存签购单
     */
    @RequiresPermissions("bankCardtype:bankCardtype:add")
    @Log(title = "签购单", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BankCardtype bankCardtype)
    {
        return toAjax(bankCardtypeService.insertBankCardtype(bankCardtype));
    }

    /**
     * 修改签购单
     */
    @GetMapping("/edit/{areacode}")
    public String edit(@PathVariable("areacode") String areacode, ModelMap mmap)
    {
        BankCardtype bankCardtype = bankCardtypeService.selectBankCardtypeById(areacode);
        mmap.put("bankCardtype", bankCardtype);
        return prefix + "/edit";
    }

    /**
     * 修改保存签购单
     */
    @RequiresPermissions("bankCardtype:bankCardtype:edit")
    @Log(title = "签购单", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BankCardtype bankCardtype)
    {
        return toAjax(bankCardtypeService.updateBankCardtype(bankCardtype));
    }

    /**
     * 删除签购单
     */
    @RequiresPermissions("bankCardtype:bankCardtype:remove")
    @Log(title = "签购单", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bankCardtypeService.deleteBankCardtypeByIds(ids));
    }
}
